<template>
  <div class="app-container">
    ssss
    <ReportForm :model-name="modelName" @changed="getData">
      //
    </ReportForm>
    <div>凭证类型: {{ data.print_journal }}</div>
    <div>科目设置: {{ wizardData.display_account__name }}</div>
    <div>会计分录: {{ wizardData.target_move__name }}</div>
    <div>排序: {{ wizardData.sortby__name }}</div>
    <div>开始时间: {{ wizardData.date_from }}</div>

    <div>
      <li v-for="item in data.Accounts" :key="item.id">
        <div>
          {{ item.code }} , {{ item.name }}, {{ item.debit }},
          {{ item.credit }}, {{ item.balance }}
        </div>
        <el-table :data="item.move_lines" style="width: 100%">
          <el-table-column
            v-for="col in columns"
            :key="col.name"
            :prop="col.name"
            :label="col.label"
          />
        </el-table>
      </li>
    </div>
  </div>
</template>

<script>
// import odoo from '@/odooapi'

import ReportForm from '@/selfComponents/Report/ReportForm'

const modelName = 'report.accounting_pdf_reports.report_general_ledger'

export default {
  name: '',
  components: { ReportForm },
  directives: {},
  filters: {},

  data() {
    return {
      modelName: modelName,
      wizardData: {},
      data: [],
      columns: [
        { name: 'ldate', label: '日期' },
        { name: 'lcode', label: '凭证类型' },
        { name: 'partner_name', label: '业务伙伴' },
        { name: 'lref', label: 'Ref' },
        { name: 'move_name', label: '凭证号' },
        { name: 'lname', label: 'Invoice' },
        { name: 'debit', label: '借方' },
        { name: 'credit', label: '贷方' },
        { name: 'balance', label: '余额' }
      ]
    }
  },
  async created() {},
  methods: {
    async getData(res) {
      console.log('xxxxxxx, detail data,', res)
      this.data = res
      this.wizardData = res.wizard_data

      // this.data = res.report_data.map(item => {
      //   return {
      //     ...item,
      //     tableData: [
      //       {
      //         date: undefined,
      //         code: undefined,
      //         a_code: '合计',
      //         a_name: undefined,
      //         displayed_name: undefined,
      //         debit: item.debit,
      //         credit: item.credit,
      //         progress: item.balance
      //       },
      //       ...item.lines
      //     ]
      //   }
      // })

      // console.log('xxxxxxx, detail data,', this.data)

      // this.data = res.report_data
    }
  }
}
</script>
